package cn.itcast.dmp.report

import cn.itcast.dmp.config.AppConfigHelper
import cn.itcast.dmp.process.ReportProcessor
import org.apache.spark.sql.{DataFrame, SparkSession}
//广告投放的APP分布报表统计
object ReportAdsAppProcessor extends ReportProcessor {
  override def targetTableName: String = {
    AppConfigHelper.REPORT_ADS_APP_TABLE_NAME
  }

  override def targetTableKeys: Seq[String] = {
    Seq("report_date", "appid", "appname")
  }

  override def realProcessData(odsDF: DataFrame): DataFrame = {
    // a. DSL分析，先将DataFrame注册为临时视图
      odsDF.createTempView("sppTable")
    // b. 执行SQL分析
    val spark: SparkSession = odsDF.sparkSession
//    val dataFrame = spark.sql(ReportSQLConstant.reportAdsAppKpiSQL("sppTable"))
    val dataFrame = spark.sql(
      ReportSQLConstant.reportAdsKpiWithSQL("sppTable",
        Seq("appid", "appname"))
    )

    dataFrame
  }
}
